﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 设计模式
{
    class Person
    {

        public Person() { }

        private string name;
        public Person(string name)
        {
            this.name = name;
        }

        public virtual void show()
        {
            Console.WriteLine("装扮的{0}", name);
        }


    }


    class Finery : Person
    {
        protected Person component;

        public void decorate(Person component)
        {
            this.component = component;

        }

        public override void show()
        {
            if (component != null)
            {

                component.show();
            }
            

        }

    }


    class Tshirts : Finery
    {
        public override void show()
        {
            Console.WriteLine("大tshirt");
            base.show();
        }


    }


    class BigTrouser : Finery
    {
        public override void show()
        {
            Console.WriteLine("垮裤");
            base.show();
        }
    }

    class Glass : Finery
    {
        public override void show()
        {
            Console.WriteLine("眼镜");
            base.show();
        }
    }

    class Mianao : Finery
    {
        public override void show()
        {
            Console.WriteLine("棉袄");
            base.show();
        }
    }


    class Fushi
    {

        public static void main()
        {
            Person xc = new Person("张然");
            Console.WriteLine("\n第一种装扮：");

            Mianao mianao = new Mianao();
            Glass glass = new Glass();
            Tshirts tshirts = new Tshirts();
            BigTrouser bigtrouser = new BigTrouser();

            bigtrouser.decorate(tshirts);
            tshirts.decorate(glass);
            glass.decorate(mianao);
            mianao.decorate(xc);

            bigtrouser.show();

            Console.Read();
        }

    }


}
